#include"Flower.h"
CFlower::CFlower(int _x, int _y, int _width, int _height)
{
	x=_x;
	y=_y;
	width=_width;
	height=_height;
	isshow=false;
	flower=new CSprite(false,0,33,width,height,0,3,0);
}
CFlower::~CFlower()
{
	if(flower!=NULL) delete flower;
}
int CFlower::CollisionWithMario(RECT marioRect)
{
	if(isover==true) return 0;  
	RECT flowerRect=flower->getRECT(x,y);
	RECT dest;
	if(IntersectRect(&dest,&flowerRect,&marioRect))
	{
		if(isshow==false)
		{
			isactive=true;
			isshow=true;
			return 0;
		}
		else 
		{
			isshow=false;
			isover=true;
			return 1;
		}
	}
	return 0;
}
void CFlower::Render(LPD3DXSPRITE sprite, LPDIRECT3DTEXTURE9 image, int time, int xcamara)
{
	if(isactive==true)
	{
		y-=32;
		isactive=false;
	}
	if(isshow==true)
	{
		flower->Next();
		flower->Render(sprite,image,x-xcamara,y);
	}
}